import java.util.Scanner;

public class TestDome1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个数字：");
        int n = scanner.nextInt();
        String str = Integer.toBinaryString(n);
        int count = 0;
        int max = 0;
        for (int i = 0; i < str.length(); i++) {
            if(str.charAt(i) == '1'){
                count++;
                max = Math.max(max,count);
            }else{
                count = 0;
            }
        }
        System.out.println(max);
    }
    //返回父节点
    public static int get(int n, int m){
        while(n != m){
            if(n > m){
                n /= 2;
            }else{
                m /= 2;
            }
        }
        return n;
    }
    public static boolean checkWon(int[][] board){
        for (int i = 0; i < 3; i++) {
           if(board[i][0] + board[i][1] + board[i][2] == 3) {
               return true;
           }
           if(board[0][i] + board[1][i] + board[2][i] == 3 ){
               return true;
           }
        }
        if(board[0][0] + board[1][1] + board[2][2] == 3){
            return true;
        }
        if(board[2][0] + board[1][1] + board[0][2] == 3){
            return true;
        }
        return false;
    }
    public static void main1(String[] args) {
        //井字棋
        int [][] board = {{1,1,-1},{1,0,1},{-1,1,1}};
        boolean ret = checkWon(board);
        System.out.println(ret);
        int n = 4;
        int m = 7;
        get(n,m);
        System.out.println(get(n,m));

        int d = 8;
        String str = Integer.toBinaryString(d);
        System.out.println(str);
    }
}
